#!/bin/sh

#
# if you want to have "conky" in your statusbar, just had this in your status.sh :
# conky | while read -r; do wmfs -s -name "$REPLY"; done
#
# Phone Kyaw Htut (htutt) <pk.htut@gmail.com>
# $ 2012 Dec 06 $

mpd() {
############
# mpd info
#
# <mpc> is required for "now playing" informations
#
if [ "`mpc 2>&1 | wc -l`" -gt "1" ]; then
if [ "`mpc | grep "^\[paused\]"`" != "" ]; then
mpd_current="`mpc current` [pause]"
else
mpd_current=`mpc current`
fi
else
mpd_current="\o/"
fi
mpd="\\#cba642\\$mpd_current"
#
############
}

RED="\\#BF4D80\\"
YEL="\\#C4A1E6\\"
GRN="\\#287373\\"
CYN="\\#6096BF\\"
MAG="\\#7E62B3\\"
GRY="\\#666666\\"
WHT="\\#C0C0C0\\"

while true;
do
    # Collect system information
    
    # For FreeBSD
    BAT=`apm -l`
    LEFT=`echo $BAT | cut -d ',' -f 2`
    VOL="$( (/usr/sbin/mixer -s vol 2> /dev/null || echo - ) | cut -d ':' -f 2 )/$( (/usr/sbin/mixer -s pcm 2> /dev/null || echo - ) | cut -d ':' -f 2 )"
    UP=`uptime | tr "," " " | cut -f4-8 -d" "`
    UPP=`uptime`
    LOAD=$(uptime | sed 's/.*://; s/,//g')
    DATE=`date +"%d.%m.%y %R:%S"`
    DATE1=`date +"%a"`
    AUTHOR=`mocp -i | grep Artist | awk -F ": " '{print $2}'`
    SONG=`mocp -i | grep SongTitle | awk -F ": " '{print $2}'`
    #MPD=`eval echo $mpd()`

    # Pipe to status bar
    wmfs -s 0 "$MPD $YEL$AUTHOR $WHT$SONG $GRY[LOAD $GRN$LOAD$GRY] $GRY[BAT $RED$BAT%$GRY] [VOL $CYN$VOL$GRY] • $WHT$DATE • $MAG$DATE1"
  sleep 5
done

# The followings are very simple status examples.
#wmfs -s "\\#FFFFFF\ `date +"%R"` \\#AAAAAA\ `date "+%Y.%m.%d. %a"` \\#FFFFFF\ bat: `apm -l`% vol/pcm ^i[190;1;0;0;/usr/home/htutt/.config/wmfs/icons/sound.png] $( (/usr/sbin/mixer -s vol 2> /dev/null || echo - ) | cut -d ':' -f 2 )/$( (/usr/sbin/mixer -s pcm 2> /dev/null || echo - ) | cut -d ':' -f 2 )"
#wmfs -s "\\#FFFFFF\ `date +"%R"` \\#AAAAAA\ `date "+%Y.%m.%d. %a"` \\#FFFFFF\ bat: `apm -l` % vol/pcm: $( (/usr/sbin/mixer -s vol 2> /dev/null || echo - ) | cut -d ':' -f 2 )/$( (/usr/sbin/mixer -s pcm 2> /dev/null || echo - ) | cut -d ':' -f 2 )"
